package com.qf.spring.aop.aspect;

import org.aspectj.lang.ProceedingJoinPoint;


public class UserAdvice {

    // 前置增强
    public void before(){
        System.out.println("前置增强执行");
    }

    // 后置增强
    public Object afterReturning(Object result){
        System.out.println("后置增强执行");
        return result;
    }

    // 前置最终增强
    public void after(){
        System.out.println("最终增强执行。");
    }

    // 环绕增强
    public Object around(ProceedingJoinPoint jp){
        Object result= null;
        try {
            System.out.println("环绕增强执行1");
            result = jp.proceed();
            System.out.println("环绕增强执行2");
        }catch (Throwable e){
            e.printStackTrace();
        }
        return result;
    }

    // 异常抛出增强
    public void throwing(){
        System.out.println("异常抛出增强执行");
    }
}
